class_name GameStateInPlay
extends GameState

func _enter_tree() -> void:
	GameEvent.team_scored_request.connect(on_team_scored.bind())

func _process(delta: float) -> void:
	manager.time_left -= delta
	if manager.is_time_up():
		if manager.current_match.is_tied():
			state_transition(GameManager.State.OVERTIME)
		else:
			state_transition(GameManager.State.GAMEOVER)
			
func on_team_scored(country_scored_on: String) -> void:
	state_transition(GameManager.State.SCORED, GameStateData.build().set_country_scored_on(country_scored_on))
